package com.whiteape.book.ui.adapter;

import android.view.View;
import android.view.ViewGroup;

import com.whiteape.book.model.dto.MediaChapterBean;
import com.whiteape.book.ui.adapter.holder.ComicCatalogHolder;
import com.whiteape.book.ui.base.EasyAdapter;
import com.whiteape.book.ui.base.adapter.IViewHolder;


/**
 * Created by newbiechen on 17-6-5.
 */

public class ComicCatalogAdapter extends EasyAdapter<MediaChapterBean> {
    private int currentSelected = 0;
    @Override
    protected IViewHolder<MediaChapterBean> onCreateViewHolder(int viewType) {
        return new ComicCatalogHolder();
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = super.getView(position, convertView, parent);
        ComicCatalogHolder holder = (ComicCatalogHolder) view.getTag();

        if (position == currentSelected){
            holder.setSelectedChapter();
        }

        return view;
    }

    public void setChapter(int pos){
        currentSelected = pos;
        notifyDataSetChanged();
    }
}
